package org.jeecg.modules.dashboard.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.dashboard.entity.Dashboard;
import org.jeecg.modules.dashboard.mapper.DashboardMapper;
import org.jeecg.modules.dashboard.service.DashboardService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.xml.crypto.Data;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @author xuganyue
 * @description 首页仪表盘统计服务实现
 * @date 2025-09-19
 */
@Service
public class DashboardServiceImpl extends ServiceImpl<DashboardMapper, Dashboard>  implements DashboardService {

    @Resource
    private DashboardMapper dashboardMapper;

    @Override
    public int getTotalSuppliers() {
        return dashboardMapper.selectTotalSuppliersInt();
    }

    @Override
    public int getOngoingProjects() {
        return dashboardMapper.selectOriginProjectsInt(); // 注意：方法名可能是 typo，建议改为 selectOngoingProjectsInt
    }

    @Override
    public int getTodayOpenTenders(Date startTime) {
        return dashboardMapper.selectTodayOpenTendersInt((Date) startTime);
    }

    @Override
    public int getActiveSuppliers(Date startTime) {
        return dashboardMapper.selectActiveSuppliersInt((Date) startTime);
    }

    @Override
    public BigDecimal getTotalAmount() {
        return dashboardMapper.selectTotalAmount();
    }
}
